//
//  BillExistCell.m
//  ForestPack
//
//  Created by 郑洲 on 2018/7/6.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "BillExistCell.h"

@interface BillExistCell ()

@property (nonatomic, strong) UILabel *brandLabel;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *typeLabel;
@property (nonatomic, strong) UILabel *moneyLabel;
@property (nonatomic, strong) UILabel *classLabel;
@property (nonatomic, strong) UILabel *timeLabel;

@property (nonatomic, strong) UIButton *leftBtn;
@property (nonatomic, strong) UIButton *rightBtn;

@end

@implementation BillExistCell

- (void)setApplyBillModel:(ApplyBillModel *)applyBillModel {
    _brandLabel.text = applyBillModel.invoice_company;
    _nameLabel.text = applyBillModel.goods_name;
    self.typeLabel.text = [NSString stringWithFormat:@"发票抬头：%@",applyBillModel.invoice_title];
    self.moneyLabel.text = [NSString stringWithFormat:@"开票金额：￥%@",applyBillModel.total_fee];
    if ([applyBillModel.invoice_type integerValue] == 1) {
        self.classLabel.text = @"发票类型：电子发票-增值普票";
    }else if ([applyBillModel.invoice_type integerValue] == 2) {
        self.classLabel.text = @"发票类型：纸质发票-增值普票";
    }else {
        self.classLabel.text = @"发票类型：纸质发票-增值专票";
    }
    self.timeLabel.text = [NSString stringWithFormat:@"开票时间：%@",applyBillModel.invoice_time];
}

+ (BillExistCell *)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellID = @"BillExistCell";
    BillExistCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[BillExistCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        [cell createSubView];
    }
    
    return cell;
}

- (void)createSubView {
    self.brandLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(14), ScreenX375(200), ScreenX375(16))];
    self.brandLabel.text = @"森林包装品牌设计";
    self.brandLabel.textColor = REXADECIMALCOLOR(@"#333333");
    self.brandLabel.font = Kfont(14);
    [self addSubview:self.brandLabel];
    
    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - ScreenX375(83), ScreenX375(5), ScreenX375(70), ScreenX375(34))];
    [button setTitle:@"订单详情 >" forState:UIControlStateNormal];
    [button setTitleColor:REXADECIMALCOLOR(@"#666666") forState:UIControlStateNormal];
    button.titleLabel.font = Kfont(12);
    [self addSubview:button];
    
    UIImageView *sLine = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(39), SCREEN_WIDTH - ScreenX375(26), 0.5)];
    sLine.image = [UIImage imageNamed:@"虚线"];
    [self addSubview:sLine];
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(49), ScreenX375(200), ScreenX375(16))];
    self.nameLabel.text = @"包装设计";
    self.nameLabel.textColor = REXADECIMALCOLOR(@"#333333");
    self.nameLabel.font = Kfont(14);
    [self addSubview:self.nameLabel];
    
    self.typeLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(77), ScreenX375(200), ScreenX375(14))];
    self.typeLabel.textColor = REXADECIMALCOLOR(@"#999999");
    self.typeLabel.font = Kfont(12);
    [self addSubview:self.typeLabel];
    
    self.moneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(96), ScreenX375(200), ScreenX375(14))];
    self.moneyLabel.textColor = REXADECIMALCOLOR(@"#999999");
    self.moneyLabel.font = Kfont(12);
    [self addSubview:self.moneyLabel];
    
    self.classLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(116), ScreenX375(200), ScreenX375(14))];
    self.classLabel.textColor = REXADECIMALCOLOR(@"#999999");
    self.classLabel.font = Kfont(12);
    [self addSubview:self.classLabel];
    
    self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(135), ScreenX375(200), ScreenX375(14))];
    self.timeLabel.textColor = REXADECIMALCOLOR(@"#999999");
    self.timeLabel.font = Kfont(12);
    [self addSubview:self.timeLabel];
    
    UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, ScreenX375(159), SCREEN_WIDTH, 0.5)];
    line.backgroundColor = LineColor;
    [self addSubview:line];
    
    self.leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(ScreenX375(164), ScreenX375(169), ScreenX375(94), ScreenX375(30))];
    self.leftBtn.layer.cornerRadius = ScreenX375(15);
    self.leftBtn.clipsToBounds = YES;
    self.leftBtn.layer.borderColor = ThemeColor.CGColor;
    self.leftBtn.layer.borderWidth = 0.5;
    [self.leftBtn setTitle:@"查看预览" forState:UIControlStateNormal];
    [self.leftBtn setTitleColor:ThemeColor forState:UIControlStateNormal];
    self.leftBtn.titleLabel.font = Kfont(14);
    [self addSubview:self.leftBtn];
    
    self.rightBtn = [[UIButton alloc] initWithFrame:CGRectMake(ScreenX375(268), ScreenX375(169), ScreenX375(94), ScreenX375(30))];
    self.rightBtn.layer.cornerRadius = ScreenX375(15);
    self.rightBtn.clipsToBounds = YES;
    self.rightBtn.layer.borderColor = ThemeColor.CGColor;
    self.rightBtn.layer.borderWidth = 0.5;
    [self.rightBtn setTitle:@"下载发票" forState:UIControlStateNormal];
    [self.rightBtn setTitleColor:ThemeColor forState:UIControlStateNormal];
    self.rightBtn.titleLabel.font = Kfont(14);
    [self addSubview:self.rightBtn];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end

@implementation ApplyBillModel

+(JSONKeyMapper*)keyMapper
{
    return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{
                                                                  @"Id": @"id",
                                                                  }];
}

@end
